package com.temp.nacos;

import java.io.IOException;
import java.net.Socket;
import java.net.UnknownHostException;

public class NacosTest {
    public static boolean isPortOpen(String ip, int port) {
        try (Socket socket = new Socket(ip, port)) {
            return true;
        } catch (UnknownHostException e) {
            System.err.println("Host unknown: " + e.getMessage());
        } catch (IOException e) {
            System.err.println("Port is not open: " + e.getMessage());
        }
        return false;
    }

    public static void main(String []args){
        System.out.println(isPortOpen("192.168.30.201",28990));
    }
}
